<template>
  <header
    class="course-header"
    :style="{
      height: typeof height === 'string' ? height : height + 'px',
      border: border,
      ...(customStyle ?? {}),
    }"
  >
    <div :class="['c-h__slot-title', fixWidth && 'fix-width']">
      <slot name="title">
        <h2 class="course-header__title">{{ title }}</h2>
      </slot>
    </div>
    <div class="c-h__slot-center">
      <slot name="center"> </slot>
    </div>
    <div :class="['c-h__slot-extra', fixWidth && 'fix-width']">
      <slot name="extra"> </slot>
    </div>
  </header>
</template>

<script setup lang="ts">
import { computed, ref, useSlots } from 'vue';
interface IProp {
  title?: string;
  height?: number | string;
  background?: string;
  border?: string;
  customStyle?: Record<string, any>;
}
const props = defineProps<IProp>();
const slots = useSlots();

const fixWidth = computed(() => {
  return !!slots.center;
});
</script>
<style lang="less" scoped>
.course-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #0000000e;
  background-color: v-bind('props.background');

  &__title {
    color: #000000e0;
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    margin: 0 !important;
  }

  .fix-width {
    width: 33%;
  }

  .c-h__slot-extra {
    display: flex;
    justify-content: flex-end;
  }
}
</style>
